package com.app.twth.ui.cyclecount;


import com.app.twth.app.Constant;
import com.app.twth.base.BaseModel;
import com.app.twth.bean.BaseResponseEntity;
import com.app.twth.net.JsonCallBack;
import com.app.twth.ui.cyclecount.location.CycleCountLocationQr;
import com.app.twth.ui.cyclecount.sku.CycleCountSkuLPNQr;
import com.app.twth.utils.GsonUtil;
import com.app.twth.utils.Utils;
import com.lzy.okgo.OkGo;

import java.util.HashMap;
import java.util.Map;

public class CycleCountDataModel extends BaseModel {
    public <T> void cycleCountSku(String barcode, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("barcode", barcode);
        OkGo.<BaseResponseEntity<T>>get(Constant.cycleCountSku)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void cycleCountSkuInfo(String ibLpn, String barcode, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("ibLpn", ibLpn);
        map.put("barcode", barcode);
        OkGo.<BaseResponseEntity<T>>get(Constant.cycleCountSkuInfo)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void cycleCountSkuSubmit(CycleCountSkuLPNQr cycleCountSkuLPNQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.cycleCountSkuSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(cycleCountSkuLPNQr))
                .execute(jsonCallBack);
    }

    public <T> void cycleCountLocationInventory(String locationCode,String ibLpn, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("locationCode", locationCode);
        if (!Utils.isEmpty(ibLpn)){
            map.put("ibLpn", ibLpn);
        }
        OkGo.<BaseResponseEntity<T>>get(Constant.cycleCountLocationInventory)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void cycleCountLocationLpnSubmit(CycleCountLocationQr cycleCountLocationQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.cycleCountLocationLpnSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(cycleCountLocationQr))
                .execute(jsonCallBack);
    }
    public <T> void cycleCountLocationSubmit(CycleCountLocationQr cycleCountLocationQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.cycleCountLocationSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(cycleCountLocationQr))
                .execute(jsonCallBack);
    }

    public <T> void getInfoByBarcode(String sku, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("sku", sku);
        OkGo.<BaseResponseEntity<T>>get(Constant.getInfoByBarcode)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }


}